
function launchFullScreen(element) {
  if(element.requestFullscreen) {
    element.requestFullscreen();
  } else if(element.mozRequestFullScreen) {
    element.mozRequestFullScreen();
  } else if(element.webkitRequestFullscreen) {
    element.webkitRequestFullscreen();
  } else if(element.msRequestFullscreen) {
    element.msRequestFullscreen();
  }
}

$(function () {

    var mainSwiper =  new Swiper('#swiper-container-1', {
        resistanceRatio : 0,
        direction: 'vertical',
        pagination: '.swiper-pagination',
        paginationBulletRender: function () {
            return '';
        },
        onTouchMove: function(swiper,direction){

        },
        onTouchEnd: function (swiper) {
            
        },

        onTransitionEnd: function(swiper){
        },
        //滑动前
        onSlideChangeStart: function(swiper){

        },
        //滑动后
        onSlideChangeEnd: function (swiper) {
        }
    })

 $(".nav-list ul li").on("click",function(){
   var idx = $(".nav-list ul li").index(this);
   mainSwiper.slideTo(idx, 1000, false);
 })


  isWachat(function(){},function(){
    $(".card-content").css("padding","6% 6%")
    $(".card-logo").css("height","26%")
    $(".model .li2").css("width","85%")
    $(".model .li2").css("height","85%")
  }, function(){})


  // 首屏 下载
  $(".downloadBtn .iosBtn").on("click", function(){
    isWachat(function(){  //微信
      Statistics("ios")
      window.open("https://itunes.apple.com/cn/app/%E9%9B%86%E5%88%86%E7%AB%9E%E5%AE%9D/id1253939312?mt=8")
    }, function(){  //微博
      $(".Bomb-box").css("display","block");
    }, function(){  //不是微博也不是微信
      Statistics("ios")
      window.open("https://itunes.apple.com/cn/app/%E9%9B%86%E5%88%86%E7%AB%9E%E5%AE%9D/id1253939312?mt=8")
    })

  })

  $(".downloadBtn .androidBtn").on("click", function(){
    isWachat(function(){  //微信
      $(".Bomb-box").css("display","block");
      // alert("微信内置浏览器暂不支持，请使用其他浏览器下载！")
    }, function(){  //微博
      $(".Bomb-box").css("display","block");
    }, function(){  //不是微博也不是微信
      Statistics("Android")
      window.location.href="http://action.ihaveu.com/downloadapp/card/android/CardGame.apk"
    })
  })

  
  $(".Bomb-box").on("click", function(){
    $(this).css("display","none")
  })

  // 第三屏 切换
  $(".model li.li2 span").on("click", function(){
    var idY = $(".model .li2>span").index(this);
    $(".pic-scroll .txt .txt-bor:nth-child("+ (idY+1) +")").addClass("active").siblings().removeClass("active");

  })

  // 第四屏 卡牌切换
  $(".card-logo").on("click", function(){
    var idx = $(".card-logo").index(this);
    $(".card-content ul:nth-child("+ (idx+1) +")").addClass("active").siblings().removeClass("active");
  })


  //  攻击类详情轮播
  var attackSwiper =  new Swiper('.attack-slide', {
        direction: 'horizontal',
       /* paginationBulletRender: function () {
            return '';
        },*/
        pagination: {
          Clickable: true,
        },
        // paginationClickable: true,
        // pagination: '.attact-pagination',
        navigation: {
          nextEl: '.attact-button-next',
          prevEl: '.attact-button-prev',
        },
        /*nextButton: '.attact-button-next',
        prevButton: '.attact-button-prev',*/
        effect: 'coverflow',
        slidesPerView: 3,
        centeredSlides: true,
        coverflowEffect: {
            rotate: 0,
            stretch: -180,
            depth: 60,
            modifier: 2,
            slideShadows: false
        },
  })

  //  防御类详情轮播
  var defenseSwiper =  new Swiper('.defense-slide', {
    direction: 'horizontal',
    // paginationBulletRender: function () {
    //   return '';
    // },
    // pagination: '.defense-pagination',
    navigation: {
      nextEl: '.defense-button-next',
      prevEl: '.defense-button-prev',
    },
    /*nextButton: '.defense-button-next',
    prevButton: '.defense-button-prev',*/
    effect: 'coverflow',
    slidesPerView: 3,
    centeredSlides: true,
    coverflowEffect: {
      rotate: 0,
      stretch: -180,
      depth: 60,
      modifier: 2,
      slideShadows: false
    },
  })
  //  控制类详情轮播
  var controlSwiper =  new Swiper('.control-slide', {
    direction: 'horizontal',
    // paginationBulletRender: function () {
    //   return '';
    // },
    // pagination: '.control-pagination',
    navigation: {
      nextEl: '.control-button-next',
      prevEl: '.control-button-prev',
    },
    /*nextButton: '.control-button-next',
    prevButton: '.control-button-prev',*/
    effect: 'coverflow',
    slidesPerView: 3,
    centeredSlides: true,
    coverflowEffect: {
      rotate: 0,
      stretch: -180,
      depth: 60,
      modifier: 2,
      slideShadows: false
    },
  })


    // 弹框
    $("ul.card1 li").on("click", function(){
      var idx = $("ul.card1 li").index(this);
      attackSwiper.slideTo(idx, 1000, false);

      $(".detailPop").show();
      $(".attack-slide").show();
      $(".attack-slide").siblings('.detail-slide').hide();
    })

    $("ul.card2 li").on("click", function(){
      var idx = $("ul.card2 li").index(this);
      defenseSwiper.slideTo(idx, 1000, false);

      $(".detailPop").show();
      $(".defense-slide").show();
      $(".defense-slide").siblings('.detail-slide').hide();
    })
    $("ul.card3 li").on("click", function(){
      var idx = $("ul.card3 li").index(this);
      controlSwiper.slideTo(idx, 1000, false);

      $(".detailPop").show();
      $(".control-slide").show();
      $(".control-slide").siblings('.detail-slide').hide();
    })

    $(".detailPop").hide(); //要在swiper初始化之后隐藏， 否则seiper初始化会失败

    //关闭弹框
    $(".detailPop .close-btn").on("click", function(){
        $(".detailPop").hide();
    })


  // 第二屏手风琴

  $(".feature ul li").on("click", function(){
    if($(this).hasClass("hover")){
      $(this).removeClass("hover")
      $(this).siblings().removeClass("active")
    }else{
      if($(this).hasClass("active")){
        $(this).siblings().removeClass("hover")
        $(this).siblings().removeClass("active")
        $(this).removeClass("active")
      }else{
        $(this).siblings().addClass("active")
        $(this).addClass("hover")
      }
    }
  })

    var myswiper = new Swiper('#swiper-container-3', {
        direction: 'horizontal',
        paginationBulletRender: function () {
            return '';
        },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev',
        },
        /*nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',*/
    })

  // 轮播图  第六屏
    var hehe = new Swiper('#swiper-container-2', {
        direction: 'horizontal',
       /* paginationBulletRender: function () {
            return '';
        },*/
        pagination: {
          el: '.raiders-pagination',
          Clickable: true
        },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev',
        },
        /*pagination: '.raiders-pagination',
        paginationClickable: true,
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',*/
        effect: 'coverflow',
        slidesPerView: 3,
        centeredSlides: true,
        coverflowEffect: {
            rotate: 0,
            stretch: -180,
            depth: 60,
            modifier: 2,
            slideShadows: false
        },
    })

  // 视频播放
  $(".video-button").on("click",function(event){

    var videoName = $(this).data("videoname")
    var videoResource

    switch(videoName)
      {
        case "introduce":
          videoResource = "http://video.zbqibing.com/fa9849c151de4f68ba1b05c42f64f533/d1625416614f409d907721c228182c5b-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "game":
          videoResource = "http://video.zbqibing.com/112b38c074da42778575e4d9d984f720/56b2fe32f4f747859ddec058b9d17597-5456d705cfd07e668f702e78be66cb6f.mp4"
          break;
        case "zhuanshang":
          videoResource = "http://video.zbqibing.com/404ce58f1fc0493b857fbc46ee512c70/125d46adb78b46f78689de239b4eb019-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "zengxiao":
          videoResource = "http://video.zbqibing.com/371ad2955de5495ea8cc3af90b28f9ad/29d344afabec4fe39f849f7a33a498ae-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "xiaohao":
          videoResource = "http://video.zbqibing.com/754f8ce331a44e629d097a01bbf41c0d/ccf617070d29457ba32dc28f7d27496e-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "wanduo":
          videoResource = "http://video.zbqibing.com/17080317ff544da380c1d74485b0b315/253ca784995e414b9253d61d2ac2290d-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "toutian":
          videoResource = "http://video.zbqibing.com/64528aebb7e141609b425d036884dd9c/3f789bdac9af4ed9a5f8b54efc1ac73a-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "shikong":
          videoResource = "http://video.zbqibing.com/abe72af3ef39443ab191de561302e806/ffc8e6f2f6d745b3a28adda8044281a9-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "pofang":
          videoResource = "http://video.zbqibing.com/80149c1a928b412d98ee2b56255e6515/57c7497d28fd4911ba4bee506089a128-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "juedou":
          videoResource = "http://video.zbqibing.com/d88973a6b9904b1db1f27957d52181b4/f2b102df0f474a809e0372cadb549ddc-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "jingu":
          videoResource = "http://video.zbqibing.com/c03fc1bc504440e3b1860a357ec21e8f/efb4677c95b14f1ba286089ed0a595c2-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "huanshi":
          videoResource = "http://video.zbqibing.com/0059fbf63a09404fadad813bec18918b/f733aaa81c6b495da19f2b4111f3f809-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "duoyao":
          videoResource = "http://video.zbqibing.com/2f997aaaae7044039de3759856d0abbc/547892d4ac8847899518c735acfc8e56-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        case "chihuan":
          videoResource = "http://video.zbqibing.com/43f17a9e350b4e3b873421e1b35830d5/591668a53fc048c4b3f2d83f95cd46c4-bebed62c6b6ebe8977b46266f0584fdc.mp4"
          break;
        default:
        
      }
    var src = videoResource
    $("video").attr("src", src)
    $('.loading').show();
      $("video")[0].play();
      launchFullScreen($("video")[0]);
      $('video')[0].oncanplay = function(){
          $('.loading').hide();
      }
    // $("video")[0].play();
    //让视频全屏自动全屏播放
    // screen.orientation.lock('landscape');
  });


    //   $('video')[0].addEventListener('canplay',function(){
    //       console.log("可以播放了")
    //       $("video")[0].play();
    //       launchFullScreen($("video")[0]);
    //       console.log("播放了")
    //       $('.loading').hide();
    //   })


    //µÚÈýÆÁµÄhover
    $('.little-title-1').on('click', function () {
        $('#swiper-container-3').css({'visibility': 'visible'});
        myswiper.initialSlide = 1;
    });

    $('.little-title-2').on('click', function () {
        $('#swiper-container-3').css({'visibility': 'visible'});
        myswiper.initialSlide = 2;
    });

    $('.little-title-3').on('click', function () {
        $('#swiper-container-3').css({'visibility': 'visible'});
        myswiper.initialSlide = 3;
    });

    $('.little-title-4').on('click', function () {
        $('#swiper-container-3').css({'visibility': 'visible'});
        myswiper.initialSlide = 4;
    });

    $('#close').on('click', function () {
        $('#swiper-container-3').css({'visibility': 'hidden'});
    });
})